<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>系统管理 - 新增人员</title>
<?php include($this->c['_homes']['_viewsHome'].'/_global/_head.php');?>
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/head.php');?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container" > 
  <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
  <?php include($this->c['_homes']['_viewsHome'].'/_global/menu.php');?>
  <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR --> 
  <!-- BEGIN PAGE -->
  <div class="page-content"> 
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title"> 新增人员 </h3>
        <ul class="page-breadcrumb breadcrumb">
          <li> <i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i> </li>
          <li> 系统管理 <i class="icon-angle-right"></i> </li>
          <li>新增人员</li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB--> 
      </div>
    </div>
    <!-- END PAGE HEADER--> 
    <!-- BEGIN PAGE CONTENT-->
    
    <div class="row">
      <div class="col-md-6"> 
        <!-- BEGIN SAMPLE FORM PORTLET-->
        <div class="portlet box blue">
          <div class="portlet-title">
            <div class="caption"> <i class="icon-reorder"></i> 人员资料 </div>
            <div class="tools"> <a href="" class="collapse"></a> </div>
          </div>
          <div class="portlet-body form">
            <form method="post" action="userdo" onsubmit="return chkusradd();">
              <input type="hidden" name="act" value="add" />
              <div class="form-body">
                <div class="form-group">
                  <label >电子邮箱</label>
                  <div class="input-group"> <span class="input-group-addon"><i class="icon-envelope"></i></span>
                    <input type="text" class="form-control" name="email" maxlength="120" onblur="chkemail(this.value);" id="_email" placeholder="请输入电子邮箱">
                  </div>
                  <span class="help-block" id="_ckemail_dis">例如：abc@qq.com</span> </div>
                <hr>
                
                <div class="form-group">
                  <label >手机号码</label>
                  <div class="input-group"> <span class="input-group-addon"><i class="icon-phone"></i></span>
                    <input type="text" class="form-control" name="mobile" id="_mobile" onblur="chkmobile(this.value);" maxlength="11" placeholder="请输入手机号码">
                  </div>
                  <span class="help-block" id="_ckmobile_dis">例如：18912345678</span> </div>
                <hr>
                
                <div class="form-group">
                  <label for="_realname">姓名</label>
                  <div class="input-group"> <span class="input-group-addon"><i class="icon-user"></i></span>
                    <input type="text" name="realname" class="form-control" id="_realname" placeholder="请输入姓名">
                  </div>
                  <span class="help-block">例如：张三</span> </div>
                <hr>
                
                
                
                <div class="form-group">
                  <label for="_password">密码</label>
                  <div class="input-group"> <span class="input-group-addon"><i class="icon-lock"></i></span>
                    <input type="password" class="form-control" id="_password" name="password" placeholder="请输入密码">
                  </div>
                  <span class="help-block">6~20个字符以内，区分大小写</span>
                </div>
                <hr>
                
                <div class="form-group">
                  <label>状态</label>
                  <div class="radio-list">
                    <label class="radio-inline">
                    <div id="uniform-optionsRadios4" class="radio"><span class="">
                      <input name="stat" id="optionsRadios4" value="1" checked type="radio">
                      </span></div>
                    <span class="label label-success">正常</span>
                    </label>
                    <label class="radio-inline">
                    <div id="uniform-optionsRadios5" class="radio"><span>
                      <input name="stat" id="optionsRadios5" value="2" type="radio">
                      </span></div>
                    <span class="label label-danger">禁用</span>
                    </label>
                  </div>
                </div>
                <hr>
                <div class="form-group">
                  <label>绑定会员UID</label>
                  <div class="input-group"> <span class="input-group-addon"><i class="icon-user"></i></span>
                    <input type="text" class="form-control" name="puid">
                  </div>
                  <span class="help-block">如果是战略合作商登录帐号，请填写会员的UID</span>
                </div>
                <hr>
                <div class="form-group">
                  <label >所属组</label>
                  <div class="input-group"> <span class="input-group-addon"><i class="icon-group"></i></span>
                    <select class="form-control" name="groupid" id="_groupid" onchange="chgpriv(this.value);">
                      <option value="">--请选择组--</option>
                      <?php
            						if($this->group){
            							foreach($this->group as $r){
            								if($r['groupid']!=88){
            					?>
                          <option value="<?=$r['groupid'];?>">
                          <?=$r['name'];?>
                          </option>
                          <?
    										 }
    									 }
    								 }
    								 ?>
                    </select>
                  </div>
                </div>
                <hr>
                
                <div class="form-group">
                  <label >权限列表</label>
                </div>
                <div class="form-group">
                  <div class="input-group" id="_privs"> 请先选择所属组</div>
                </div>
              </div>
              <div class="form-actions">
                <input type="submit" class="btn blue" value="提 交">
              </div>
            </form>
          </div>
        </div>
        <!-- END SAMPLE FORM PORTLET--> 
        
      </div>
    </div>
    <!-- END PAGE CONTENT--> 
  </div>
  <!-- END PAGE --> 
</div>
<!-- END CONTAINER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/_footer.php');?>
<script>
	jQuery(document).ready(function() {    
	   App.init();
	});
</script> 
<script type="text/javascript">
var pe=/^([_a-zA-Z0-9]+([\._a-zA-Z0-9-]+)*)@([a-z0-9-]{1,}(\.[a-z0-9-]{2,})*\.[a-z]{2,3})$/,
	pm=/^(13|14|15|17|18)([0-9]{9})$/;
function prvskall(itm){
var _ns = document.getElementsByName("PRIVS[]");
	if(_ns.length>0){
		for(var i = 0; i<_ns.length;i++){
			var _ar = _ns[i].value.split("_");
			if(_ar[0]==itm.value) _ns[i].checked = itm.checked;
		}
	}
}

function prvskpart(fa){
var _ck = document.getElementsByName("CKALL[]");
var _ns = document.getElementsByName("PRIVS[]");
var _ckd = true;
	if(_ns.length>0){
		for(var i = 0; i<_ns.length;i++){
			var _ar = _ns[i].value.split("_");
			if(_ar[0]==fa){
				if(!_ns[i].checked){
				_ckd=false;
				break;
				}
			}
		}
	}
	
	if(_ck.length>0){
		for(var j = 0; j<_ck.length;j++){
			if(_ck[j].value==fa){
			_ck[j].checked = _ckd;
			break;
			}
		}	
	}
}

function chgpriv(gpid){
	if(gpid!="" && parseInt(gpid)>0){
		$.ajax({
		type: "POST",
		url: "userajax",
		data: "act=chgpriv&groupid="+gpid+"&mr="+Math.random(),
		success: function(msg){
		$("#_privs").html(msg);
		}
		});
	}else{
	$("#_privs").html('请先选择所属组');
	}	
}

function chkemail(usr){
	if(usr!=""){
		
		if(pe.test(usr)){
		
			$.ajax({
			type: "POST",
			url: "userajax",
			data: "act=chkemail&email="+encodeURI(usr)+"&mr="+Math.random(),
			success: function(msg){
			$("#_ckemail_dis").html(msg);		
			}
			});
		}
		else $("#_ckemail_dis").html('<span class="text-danger">电子邮箱格式错误</span>');
	}
	else $("#_ckemail_dis").html('<span class="text-danger">请填写电子邮箱</span>');
}

function chkmobile(usr){
	if(usr!=""){
		
		if(pm.test(usr)){
		
			$.ajax({
			type: "POST",
			url: "userajax",
			data: "act=chkmobile&mobile="+encodeURI(usr)+"&mr="+Math.random(),
			success: function(msg){
			$("#_ckmobile_dis").html(msg);		
			}
			});
		}
		else $("#_ckmobile_dis").html('<span class="text-danger">手机号码格式错误</span>');
	}
	else $("#_ckmobile_dis").html('<span class="text-danger">请填写手机号码</span>');
}

function chkusradd(){
	if($("#_email").prop("value")==""){
		alert("请填写电子邮箱");
		$("#_email").focus();
		return false;
	}
	
	if($("#_mobile").prop("value")==""){
		alert("请填写手机号码");
		$("#_mobile").focus();
		return false;
	}
	
	if($("#_realname").prop("value")==""){
		alert("请填写姓名");
		$("#_realname").focus();
		return false;
	}
	
	if($("#_password").prop("value").length<6 ||$("#_password").prop("value").length>20 ){
		alert("请填写密码，且长度必须在6~20以内");
		$("#_password").focus();
		return false;
	}
	
	if($("#_groupid").val()==""){
		alert("请填写所属组");
		$("#_groupid").focus();
		return false;
	}
}
</script> 
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>